#include <vector>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

#include "include/PetCtrl.h"
#include "include/Pet.h"
#include "include/Utils.h"
#include "include/EventParser.h"

using namespace boost::property_tree;

void PetCtrl::GetBaseInfo(GlobalGameObj *p_game_obj)
{
#ifdef _DEBUG_LEVEL_1_
	cout << __FUNCTION__ << " in" << endl;
#endif

	int pet_id;
	try
	{
		pet_id = p_game_obj->in_tree.get<int>("petId");

	}
	catch(exception &ex)
	{
		p_game_obj->error_code = Common::JsonTreeError;
		p_game_obj->error_str = "in GetPetBaseInfo";
		return;
	}

	ptree info_tree;
	Pet::GetBasicInfoTree(p_game_obj, pet_id, info_tree);
	if(Common::NoError != p_game_obj->error_code)
	{
	    return;
	}

	info_tree.put("evt", "Pet_BaseInfo");
	info_tree.put("code", 0);

	p_game_obj->out_tree.push_back(make_pair("", info_tree));

	p_game_obj->out_format_tree.put("dataType", Common::NormalData);

	cout << "out_format_tree:dataType: " << p_game_obj->out_format_tree.get<int>("dataType") << endl;
}

void PetCtrl::GetDetailInfo(GlobalGameObj *p_game_obj)
{
    int pet_id;
	try
	{
	    // because player can query other player's info, character id is needed
		pet_id = p_game_obj->in_tree.get<int>("petId");

	}
	catch(exception &ex)
	{
		p_game_obj->error_code = Common::JsonTreeError;
		p_game_obj->error_str = "in GetPetDetailInfo";
		return;
	}

	ptree info_tree;
	Pet::GetDetailInfoTree(p_game_obj, pet_id, info_tree);

	info_tree.put("evt", "Pet_DetailInfo");
	info_tree.put("code", 0);

    p_game_obj->out_tree.push_back(make_pair("", info_tree));
    p_game_obj->out_format_tree.put("dataType", Common::NormalData);
}
